www.gusucode.com > 超声波测量以及形成图像 对相关信号进行模拟仿真 > 超声波测量以及形成图像 对相关信号进行模拟仿真/digital holograpy/prog/slctout.m
function a = slctout( m,n ) %SLCTOUT Select n diffrent numbers from [1:m] randomly, and put them into a % Syntax: % a=slctout(m,n); % % m and n must be integers % m should be bigger than or equal to n % if m<n error('The first input should not be smaller than the second.') end % a=1:m; for k=1:n t=ceil(rand*(m-k+1)+k-1); if t~=k s=a(t); a(t)=a(k); a(k)=s; end end a=a(1:n);